package behavior.Iterator;

import java.util.Collections;
import java.util.List;

/**
 * Created by LYJ on 2016/10/20.
 * 具体迭代器角色
 */
public class ConcreteIterator implements Iterator{
    private List<Object> list= Collections.emptyList();
    private int current=0;

    public ConcreteIterator(List<Object> list) {
        this.list = list;
    }

    @Override
    public Object next() {
        Object obj=null;
        if (hasNext())
            obj=list.get(current++);

        return obj;
    }

    @Override
    public boolean hasNext() {
        if(current==list.size())
            return false;
        return true;
    }
}
